<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN""http://www.w3.org/TR/html4/loose.dtd">
<HTML
><HEAD
><TITLE
>Building GCC</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.79"/><LINK
REL="HOME"
TITLE="Cygwin/X Contributor's Guide"
HREF="cygwin-x-cg.html"/><LINK
REL="UP"
TITLE="Building a cross-compiler"
HREF="cross.html"/><LINK
REL="PREVIOUS"
TITLE="Building binutils"
HREF="cross-building-binutils.html"/><LINK
REL="NEXT"
TITLE="GNU Free Documentation License"
HREF="gfdl.html"/><META
HTTP-EQUIV="Content-Type"
CONTENT="text/html;charset=utf-8"/></HEAD
><BODY
CLASS="sect1"
><DIV
CLASS="NAVHEADER"
><TABLE
SUMMARY="Header navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TH
COLSPAN="3"
ALIGN="center"
>Cygwin/X Contributor's Guide</TH
></TR
><TR
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="bottom"
><A
HREF="cross-building-binutils.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
>Appendix A. Building a cross-compiler</TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="gfdl.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"/></DIV
><DIV
CLASS="sect1"
><H1
CLASS="sect1"
><A
NAME="cross-building-gcc"
>Building GCC</A
></H1
><OL
TYPE="1"
><LI
><P
>Change the current directory to the <TT
CLASS="filename"
>~/cygwin/src/</TT
> directory:</P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><PRE
CLASS="screen"
>&#13;user@crosshost ~ $ cd ~/cygwin/src
</PRE
></TD
></TR
></TABLE
></LI
><LI
><P
>Extract the GCC archive, then extract the upstream GCC
source archive and apply the patches it contains :</P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><PRE
CLASS="screen"
>&#13;user@crosshost ~/cygwin/src $ tar jxf gcc4-4.5.0-1-src.tar.bz2
user@crosshost ~/cygwin/src $ tar jxf gcc-4.5.0.tar.bz2
user@crosshost ~/cygwin/src $ <SPAN
CLASS="emphasis"
><I
CLASS="emphasis"
>(patching and autoreconf commands omitted)</I
></SPAN
>
</PRE
></TD
></TR
></TABLE
><UL
><LI
><P
>&#13;Where the patches touch the configuration mechanism, you need to
regenerate the files generated by autotools.
autoreconf doesn't work, I don't know why, so you need to invoke
the correct autotools in the correct directories.  The cygport
file provides an example of how to do this.
</P
></LI
><LI
><P
>&#13;GCC is picky about the exact versions of the autotools in use, so
you need to make the versions it requires available.
</P
></LI
><LI
><P
>&#13;For bonus points, use <B
CLASS="command"
>cygport prep</B
> to extract
the source and apply the patches.
</P
></LI
></UL
></LI
><LI
><P
>Create a
<TT
CLASS="filename"
>~/cygwin/build/gcc-4.5.0-1/</TT
> directory
and change the current directory to that directory:
</P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><PRE
CLASS="screen"
>&#13;user@crosshost ~/cygwin/src $ mkdir ~/cygwin/build/gcc-4.5.0
user@crosshost ~/cygwin/src $ cd ~/cygwin/build/gcc-4.5.0
</PRE
></TD
></TR
></TABLE
><UL
><LI
><P
>&#13;It's highly recommended that GCC be built into a separate directory from
the sources which does not reside within the source tree.
Building GCC in the source directory is generally untested, and building
into a subdirectory of the source directory is unsupported.
</P
></LI
></UL
></LI
><LI
><P
>Configure GCC:</P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><PRE
CLASS="screen"
>&#13;user@crosshost ~/cygwin/build/gcc-4.5.0 $ ../../src/gcc-4.5.0/configure --prefix=/home/user/cygwin --target=i686-pc-cygwin \
--disable-bootstrap --enable-version-specific-runtime-libs --enable-static --enable-shared --enable-shared-libgcc \
--disable-__cxa_atexit --disable-sjlj-exceptions --enable-languages=c,c++ --disable-symvers --enable-threads=posix \
2&gt;&amp;1 | tee configure.log
</PRE
></TD
></TR
></TABLE
><UL
><LI
><P
>&#13;Use the same configure options as used in the cygport file or reported by gcc -v
</P
></LI
></UL
></LI
><LI
><P
>Build GCC:</P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><PRE
CLASS="screen"
>&#13;user@crosshost ~/cygwin/build/gcc-4.5.0-1 $ make all 2&gt;&amp;1 | tee all.log
</PRE
></TD
></TR
></TABLE
></LI
><LI
><P
>Install GCC:</P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><PRE
CLASS="screen"
>&#13;user@crosshost ~/cygwin/build/gcc-4.5.0-1 $ make install 2&gt;&amp;1 | install.log
</PRE
></TD
></TR
></TABLE
></LI
></OL
><P
>&#13;Building binutils and GCC is now complete.
Test your cross-compiler by checking that a 'hello world' program can be
successfully compiled on your build host and run on your Cygwin target host.
</P
></DIV
><DIV
CLASS="NAVFOOTER"
><HR
ALIGN="LEFT"
WIDTH="100%"/><TABLE
SUMMARY="Footer navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
><A
HREF="cross-building-binutils.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="cygwin-x-cg.html"
ACCESSKEY="H"
>Home</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
><A
HREF="gfdl.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>Building binutils</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="cross.html"
ACCESSKEY="U"
>Up</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>GNU Free Documentation License</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>